package demo13

// 策略设计模式

// 设计分析 支付Payment  <支付内容:PaymentContext, 支付方式:strategy[对象]>【方法:pay()支付动作,】
// 支付内容PaymentContext <姓名:Name 卡号:cardId 金额:money>

type Payment struct{
	context *PaymentContext
	strategy PaymentStrategy
}

type PaymentContext {
	Name,CardId string
	Money float64
}

type PaymentStrategy interface{
	Pay(*PaymentContext)
}

func NewPayment(name,cardId string, money float64, strategy PaymentStrategy) *Payment{
	return &Payment{
		context:&PaymentContext{
			Name:name,
			CardId:cardId,
			Money:money,
		},
		strategy:strategy,
	}
}

func (p *Payment)Pay(){
	p.strategy.Pay(p.PaymentContext)
}

type Cash struct{
	method string
	cost  float64
}

func (c *Cash)Pay(*PaymentContext){
	// ----cash -----
}

type Bank struct{
	method string
	cost float64
}
func (b *Bank)Pay(*PaymentContext){
	// ----bank-----
}